package com.example.kotlin

import com.example.kotlin.lifecycle.Lifecycle
import com.example.kotlin.lifecycle.LifecycleObserver

/**
 * @ClassName: Player
 * @Description: java类作用描述
 * @Author: chenmengjia
 * @Date: 2022/2/2 14:11
 */
class Player2(var name: String, var age: Int, var lifeCycle: Lifecycle? = null) :
    LifecycleObserver {

    init {

        lifeCycle?.addListener(this)
    }

    //次构造方法调用柱构造方法
    constructor(name: String) : this(name, age = 0) {
        this.name = name.toLowerCase()
        this.age = age+12
    }

    override fun onStart() {

    }

    override fun onStop() {

    }

    override fun onDestroy() {

        lifeCycle?.removeListener(this)

    }


}